<?php
declare(strict_types=1);

namespace WebApp\lib\exception;

use Exception;
use Throwable;
use txz\common\base\utils\LogHelper;
use txz\common\base\utils\MonitorHelper;

/**
 * Class ParamErrorException
 * @package txz\common\third_lib\model\exception
 */
class ErrException extends Exception
{
    public function __construct(string $tag, $why='', int $code = 0, Throwable $previous = null)
    {
        $message = $tag . ":" . is_array($why)? json_encode($why):$why;
        LogHelper::logE($message);
        MonitorHelper::monitorFatal(str_replace($tag, '_', ' '));
        parent::__construct($message, $code, $previous);
    }
}